home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SGI Performance Co-Pilot 1.3
/
SGI Performance Co-Pilot 1.3.iso
/
dist
/
dist6.4
/
pcp.idb
/
usr
/
include
/
pcp
/
impl.h.z
/
impl.h
Wrap
C/C++ Source or Header
|
1997-04-03
|
28KB
|
891 lines
/*
* Copyright 1995, Silicon Graphics, Inc.
* ALL RIGHTS RESERVED
*
* UNPUBLISHED -- Rights reserved under the copyright laws of the United
* States. Use of a copyright notice is precautionary only and does not
* imply publication or disclosure.
*
* U.S. GOVERNMENT RESTRICTED RIGHTS LEGEND:
* Use, duplication or disclosure by the Government is subject to restrictions
* as set forth in FAR 52.227.19(c)(2) or subparagraph (c)(1)(ii) of the Rights
* in Technical Data and Computer Software clause at DFARS 252.227-7013 and/or
* in similar or successor clauses in the FAR, or the DOD or NASA FAR
* Supplement. Contractor/manufacturer is Silicon Graphics, Inc.,
* 2011 N. Shoreline Blvd. Mountain View, CA 94039-7311.
*
* THE CONTENT OF THIS WORK CONTAINS CONFIDENTIAL AND PROPRIETARY
* INFORMATION OF SILICON GRAPHICS, INC. ANY DUPLICATION, MODIFICATION,
* DISTRIBUTION, OR DISCLOSURE IN ANY FORM, IN WHOLE, OR IN PART, IS STRICTLY
* PROHIBITED WITHOUT THE PRIOR EXPRESS WRITTEN PERMISSION OF SILICON
* GRAPHICS, INC.
*
* $Id: impl.h,v 2.50 1997/03/26 02:31:03 kenmcd Exp $
*/
#ifndef _IMPL_H
#define _IMPL_H
#include <unistd.h>
#include <sys/types.h>
#include <sys/param.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <ndbm.h>
#include <time.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* This defines the routines, macros and data structures that are used
* in the Performance Metrics Collection Subsystem (PMCS) below the
* PMAPI.
*/
/* PMCD connections have to come here ... */
#define SERVER_PORT 4321
/*
* Internally, this is how to decode a PMID!
*/
typedef struct {
int pad:2;
unsigned int domain:8;
unsigned int cluster:12;
unsigned int item:10;
} _pmID_int;
/*
* Internally, this is how to decode a Instance Domain Identifier!
*/
typedef struct {
int pad:2;
unsigned int domain:8; /* the administrative PMD */
unsigned int serial:22; /* unique within PMD */
} _pmInDom_int;
/*
* internal structure of a PMNS node
*/
typedef struct pn_s {
struct pn_s *parent;
struct pn_s *next;
struct pn_s *first;
struct pn_s *hash; /* used as "last" in build, then pmid hash synonym */
char *name;
pmID pmid;
} _pmnsNode;
/* only used by pmnscomp ... */
extern void _pmExportPMNS(_pmnsNode **, int *, _pmnsNode ***);
/* standard log file set up */
extern FILE *_pmOpenLog(char *, char *, FILE *, int *);
/* make _pmNotifyErr also add entries to syslog */
extern void _pmSyslog(int);
/* standard error, warning and info wrapper for syslog(3C) */
extern void _pmNotifyErr(int, const char *, ...);
/*
* These ones are only for debugging and may not appear in the shipped
* libpmapi ...
*/
extern int pmDebug;
/* debug control bit fields */
#define DBG_TRACE_PDU 1 /* reserved for libpcp */
#define DBG_TRACE_FETCH 2
#define DBG_TRACE_PROFILE 4
#define DBG_TRACE_CONV 8
#define DBG_TRACE_CONTEXT 16
#define DBG_TRACE_INDOM 32
#define DBG_TRACE_PDUBUF 64
#define DBG_TRACE_LOG 128
#define DBG_TRACE_LOGMETA 256
#define DBG_TRACE_OPTFETCH 512
#define DBG_TRACE_AF 1024
#define DBG_TRACE_APPL0 2048 /* reserved for applications */
#define DBG_TRACE_APPL1 4096
#define DBG_TRACE_APPL2 8192
#define DBG_TRACE_PMNS 16384 /* more for libpcp */
#define DBG_TRACE_LIBPMDA 32768 /* libpmda */
#define DBG_TRACE_TIMECONTROL 65536 /* time control api */
extern void _pmDumpResult(FILE *, pmResult *);
extern void _pmPrintStamp(FILE *, struct timeval *);
extern void _pmFreeResultValues(pmResult *);
extern char *_pmPDUTypeStr(int);
extern void _pmDumpNameSpace(FILE *, int);
/*
* struct timeval is sometimes 2 x 64-bit ... we use a 2 x 32-bit format for
* PDUs, internally within libpcp and for (external) archive logs
*/
typedef struct {
__int32_t tv_sec; /* seconds since Jan. 1, 1970 */
__int32_t tv_usec; /* and microseconds */
} _pmTimeval;
/*
* Logs and archives of performance metrics (not to be confused
* with diagnostic logs for error messages, etc.)
*
* _pmLogCtl log control
* _pmLogTI temporal index record
*/
/*
* Hashed Data Structures for the Processing of Logs and Archives
*/
typedef struct _hashnode {
struct _hashnode *next;
int key;
void *data;
} _pmHashNode;
typedef struct {
int nodes;
int hsize;
_pmHashNode **hash;
} _pmHashCtl;
extern _pmHashNode *_pmHashSearch(int, _pmHashCtl *);
extern int _pmHashAdd(int, void *, _pmHashCtl *);
extern int _pmHashDel(int, void *, _pmHashCtl *);
/*
* External file and internal (below PMAPI) format for an archive label
*/
typedef struct {
int ill_magic; /* PM_LOG_MAGIC | log format version no. */
pid_t ill_pid; /* PID of logger */
_pmTimeval ill_start; /* start of this log */
int ill_vol; /* current log volume no. */
char ill_hostname[MAXHOSTNAMELEN]; /* name of collection host */
char ill_tz[40]; /* $TZ at collection host */
} _pmLogLabel;
/*
* unfortunately, in this version, PCP archives are limited to no
* more than 2 Gbytes ...
*/
typedef __uint32_t pm_off_t;
/*
* Temporal Index Record
*/
typedef struct {
_pmTimeval ti_stamp; /* now */
int ti_vol; /* current log volume no. */
pm_off_t ti_meta; /* end of meta data file */
pm_off_t ti_log; /* end of metrics log file */
} _pmLogTI;
/*
* Log/Archive Control
*/
typedef struct {
int l_refcnt; /* number of contexts using this log */
char *l_name; /* external log base name */
FILE *l_tifp; /* temporal index */
FILE *l_mdfp; /* meta data */
FILE *l_mfp; /* current metrics log */
int l_curvol; /* current metrics log volume no. */
int l_state; /* (when writing) log state */
_pmHashCtl l_hashpmid; /* PMID hashed access */
_pmHashCtl l_hashindom; /* instance domain hashed access */
_pmHashCtl l_hashrange; /* ptr to first and last value in log for */
/* each metric */
int l_minvol; /* (when reading) lowest known volume no. */
int l_maxvol; /* (when reading) highest known volume no. */
int l_numseen; /* (when reading) size of l_seen */
int *l_seen; /* (when reading) volumes opened OK */
_pmLogLabel l_label; /* (when reading) log label */
pm_off_t l_physend; /* (when reading) offset to physical EOF */
/* for last volume */
_pmTimeval l_endtime; /* (when reading) timestamp at logical EOF */
int l_numti; /* (when reading) no. temporal index entries */
_pmLogTI *l_ti; /* (when reading) temporal index */
} _pmLogCtl;
/* l_state values */
#define PM_LOG_STATE_NEW 0
#define PM_LOG_STATE_INIT 1
/*
* Dump the current context (hostname + instance profile), for a
* particular instance domain
* If indom == PM_INDOM_NULL, then print all all instance domains
*/
extern void _pmDumpContext(FILE *, int, pmInDom);
/*
* translate a PMDA name into a path for a file that exists
* - uses /usr/pcp/lib and /var/pcp/lib toggling
* - support PMDA_PATH for relative filenames
*/
extern char *_pmFindPMDA(char *);
/*
* instance profile states
*/
#define PM_PROFILE_INCLUDE 0 /* include all, exclude some */
#define PM_PROFILE_EXCLUDE 1 /* exclude all, include some */
/* Profile entry (per instance domain) */
typedef struct {
pmInDom indom; /* instance domain */
int state; /* include all or exclude all */
int instances_len; /* length of instances array */
int *instances; /* array of instances */
} _pmInDomProfile;
/* Instance profile for all domains */
typedef struct {
int state; /* default global state */
int profile_len; /* length of profile array */
_pmInDomProfile *profile; /* array of instance profiles */
} _pmProfile;
/*
* Dump the instance profile, for a particular instance domain
* If indom == PM_INDOM_NULL, then print all instance domains
*/
extern void _pmDumpProfile(FILE *, int, _pmProfile *);
/*
* Result structure for instance domain queries
* Only the PMD agents and pmcd need to know about this.
*/
typedef struct {
pmInDom indom; /* instance domain */
int numinst; /* may be 0 */
int *instlist; /* instance ids, may be NULL */
char **namelist; /* instance names, may be NULL */
} _pmInResult;
extern void _pmDumpInResult(FILE *, _pmInResult *);
/* instance profile methods */
extern int _pmGetFd(void);
extern _pmProfile *_pmCurProfile(void);
extern int _pmProfileSetSent(void);
extern void _pmFreeProfile(_pmProfile *);
extern _pmInDomProfile *_pmFindProfile(pmInDom, _pmProfile *);
extern int _pmInProfile(pmInDom, _pmProfile *, int);
extern void _pmFreeInResult(_pmInResult *);
/*
* Control for connection to a PMCD
*/
typedef struct {
int pc_refcnt; /* number of contexts using this socket */
char *pc_name; /* host name */
int pc_fd[2]; /* socket for comm with pmcd */
/* ... -1 means no connection */
int pc_timeout; /* set if connect times out */
time_t pc_again; /* time to try again */
} _pmPMCDCtl;
/*
* per context controls for archives and logs
*/
typedef struct {
_pmLogCtl *ac_log; /* global logging and archive control */
long ac_offset; /* fseek ptr for archives */
int ac_vol; /* volume for ac_offset */
int ac_serial; /* serial access pattern for archives */
_pmHashCtl ac_pmid_hc; /* per PMID controls for INTERP */
} _pmArchCtl;
/*
* PMAPI context. We keep an array of these,
* one for each context created by the application.
*/
typedef struct {
int c_type; /* PM_CONTEXT_HOST, _ARCHIVE or _FREE */
int c_mode; /* current mode PM_MODE_* */
_pmPMCDCtl *c_pmcd; /* pmcd control for HOST contexts */
_pmArchCtl *c_archctl; /* log control for ARCHIVE contexts */
_pmTimeval c_origin; /* pmFetch time origin / current time */
int c_delta; /* for updating origin */
int c_mux; /* PM_COLL_NOW or PM_COLL_VCR */
int c_sent[2]; /* profile has been sent to pmcd */
_pmProfile *c_instprof; /* instance profile */
} _pmContext;
#define PM_CONTEXT_FREE -1 /* special type */
#define PM_COLL_NOW 0 /* pmcd */
#define PM_COLL_VCR 1 /* pmvcr */
/* handle to _pmContext pointer */
extern _pmContext *_pmHandleToPtr(int);
/*
* Protocol data unit support
*/
typedef struct {
int len; /* length of pdu_header + PDU */
int type; /* PDU type */
int from; /* pid of PDU originator */
} _pmPDUHdr;
typedef int _pmPDU;
#define PDU_PROTOCOL_VERSION 1
/* ASCII PDU line buffer */
#define ABUFSIZE 256
extern char _pmAbuf[ABUFSIZE];
extern int _pmXmitPDU(int, _pmPDU *);
extern int _pmXmitAscii(int, char *, int);
extern int _pmGetPDU(int, int, int, _pmPDU * *);
/* for _pmGetPDU */
#define TIMEOUT_NEVER 0
#define TIMEOUT_DEFAULT -1
#define GETPDU_ASYNC -2
extern int _pmRecvPDU(int, int, _pmPDU * *); /* old interface to _pmGetPDU */
extern int _pmRecvLine(_pmPDU *, int, char *);
extern int _pmGetFd(void);
extern _pmPDU *_pmFindPDUBuf(int);
extern void _pmPinPDUBuf(void *);
extern int _pmUnpinPDUBuf(void *);
#define PDU_ERROR 0x7000
#define PDU_RESULT 0x7001
#define PDU_PROFILE 0x7002
#define PDU_FETCH 0x7003
#define PDU_DESC_REQ 0x7004
#define PDU_DESC 0x7005
#define PDU_INSTANCE_REQ 0x7006
#define PDU_INSTANCE 0x7007
#define PDU_TEXT_REQ 0x7008
#define PDU_TEXT 0x7009
#define PDU_CONTROL_REQ 0x700a
#define PDU_DATA_X 0x700b
/*
* PDU encoding formats
*/
#define PDU_BINARY 0
#define PDU_ASCII 1
extern int _pmSendError(int, int, int);
extern int _pmDecodeError(_pmPDU *, int, int *);
extern int _pmSendResult(int, int, pmResult *);
extern int _pmDecodeResult(_pmPDU *, int, pmResult **);
extern int _pmSendProfile(int, int, int, _pmProfile *);
extern int _pmDecodeProfile(_pmPDU *, int, int *, _pmProfile **);
extern int _pmSendFetch(int, int, int, _pmTimeval *, int, pmID *);
extern int _pmDecodeFetch(_pmPDU *, int, int *, _pmTimeval *, int *, pmID **);
extern int _pmSendDescReq(int, int, pmID);
extern int _pmDecodeDescReq(_pmPDU *, int, pmID *);
extern int _pmSendDesc(int, int, pmDesc *);
extern int _pmDecodeDesc(_pmPDU *, int, pmDesc *);
extern int _pmSendInstanceReq(int, int, _pmTimeval *, pmInDom, int, char *);
extern int _pmDecodeInstanceReq(_pmPDU *, int, _pmTimeval *, pmInDom *, int *, char **);
extern int _pmSendInstance(int, int, _pmInResult *);
extern int _pmDecodeInstance(_pmPDU *, int, _pmInResult **);
extern int _pmSendTextReq(int, int, int, int);
extern int _pmDecodeTextReq(_pmPDU *, int, int *, int *);
extern int _pmSendText(int, int, int, char *);
extern int _pmDecodeText(_pmPDU *, int, int *, char **);
extern int _pmSendControlReq(int, int, pmResult *, int, int, int);
extern int _pmDecodeControlReq(_pmPDU *, int, pmResult **, int *, int *, int *);
extern int _pmSendDataX(int, int, int, int, void *);
extern int _pmDecodeDataX(_pmPDU *, int, int *, int *, void **);
#if _MIPS_SZLONG == 64
/*
* A pmValue contains the union of a 32-bit int and a pointer. In the world
* of 64-bit pointers, a pmValue is therefore larger than in the 32-bit world.
* The structures below are used in all PDUs containing pmResults to ensure
* 32-bit and 64-bit programs exchanging PDUs can communicate.
* Note that a pmValue can only hold a 32-bit value in situ regardless of
* whether the pointer size is 32 or 64 bits.
*/
typedef struct {
int inst; /* instance identifier */
union {
unsigned int pval; /* offset into PDU buffer for value */
int lval; /* 32-bit value in situ */
} value;
} _pmValue_PDU;
typedef struct {
pmID pmid; /* metric identifier */
int numval; /* number of values */
int valfmt; /* value style */
_pmValue_PDU vlist[1]; /* set of instances/values */
} _pmValueSet_PDU;
#elif _MIPS_SZLONG == 32
/* In the 32-bit world, structures may be used in PDUs as defined */
typedef pmValue _pmValue_PDU;
typedef pmValueSet _pmValueSet_PDU;
#else
bozo - unknown _MIPS_SZLONG!!!;
#endif
/*
* If you use help files created via "newhelp" and ndbm(3B), then
* this is the key you should use, i.e. dptr -> _pmHelpKey and
* dsize = sizeof(_pmHelpKey)
*/
typedef struct {
int ident; /* PMID or InDom */
int type;
} _pmHelpKey;
/*
* The "type" field is PM_TEXT_ONELINE or PM_TEXT_HELP with one of
* the following "ident" qualifiers or'd in
*/
#define PM_TEXT_PMID 4
#define PM_TEXT_INDOM 8
/*
* alternatively, open the ndbm file(s) with ndbm_open() and then
* use ...
*/
extern char *_pmGetText(DBM *, int, int);
/*
* Quick-and-dirty pool memory allocator ...
*/
extern void *_pmPoolAlloc(size_t);
extern void _pmPoolFree(void *, size_t);
/*
* no mem today, my love has gone away ....
*/
extern void _pmNoMem(char *, size_t, int);
#define PM_FATAL_ERR 1
#define PM_RECOV_ERR 0
/*
* nodelock license check
*/
extern int _pmGetLicense(int, char *, int);
extern int _pmGetLicenseCap(void);
#define PM_LIC_COL 1
#define PM_LIC_MON 2
#define PM_LIC_PCP 4
#define PM_LIC_WEB 8
#ifdef DEBUG
#define PM_LIC_DEV 16384 /* for development and testing */
#endif
/*
* execution states ... PM_STATE_APPL means we are at or above the
* PMAPI in a state where PMAPI calls can safely be made ... PM_STATE_PMCS
* means we are in the PMCD, or a PMDA, or low-level PDU code, and
* PMAPI calls are a bad idea.
*/
extern int _pmState;
#define PM_STATE_APPL 0
#define PM_STATE_PMCS 1
/*
* program name, as used in _pmNotifyErr() ... default is "pcp"
*/
extern char *pmProgname;
/* agent-PMCD PDU readiness codes */
#define PMDA_STS_READY -2048 /* PMDA willing and able to process PDUs */
#define PMDA_STS_NOT_READY -2049 /* PMDA unable to process PDUs */
/* map Unix errno values to PMAPI errors */
extern int _pmMapErrno(int);
/*
* _pmLogInDom is used to hold the instance identifiers for an instance
* domain internally ... if multiple sets are observed over time, these
* are linked together in reverse chronological order
* -- externally we write these as
* timestamp
* indom <- note, added wrt indom_t
* numinst
* inst[0], .... inst[numinst-1]
* nameindex[0] .... nameindex[numinst-1]
* string (name) table, all null-byte terminated
*/
typedef struct _indom_t {
struct _indom_t *next;
_pmTimeval stamp;
int numinst;
int *instlist;
char **namelist;
} _pmLogInDom;
/*
* record header in the metadata log file ... len (by itself) also is
* used as a trailer
*/
typedef struct {
int len; /* record length, includes header and trailer */
int type; /* see TYPE_* #defines below */
} _pmLogHdr;
#define TYPE_DESC 1 /* header, pmDesc, trailer */
#define TYPE_INDOM 2 /* header, _pmLogInDom, trailer */
extern void _pmLogPutIndex(_pmLogCtl *, _pmTimeval *);
extern char *_pmLogName(char *, int);
extern FILE *_pmLogNewFile(char *, int);
extern int _pmLogCreate(char *, char *, _pmLogCtl *);
extern int _pmLogRead(_pmLogCtl *, int, FILE *, pmResult **);
extern int _pmLogWriteLabel(FILE *, _pmLogLabel *);
extern int _pmLogOpen(char *, _pmContext *);
extern int _pmLogLoadMeta(_pmLogCtl *);
extern void _pmLogClose(_pmLogCtl *);
extern int _pmLogPutDesc(_pmLogCtl *, pmDesc *);
extern int _pmLogLookupDesc(_pmLogCtl *, pmID, pmDesc *);
extern int _pmLogPutInDom(_pmLogCtl *, pmInDom, _pmTimeval *, int, int *, char **);
extern int _pmLogGetInDom(_pmLogCtl *, pmInDom, _pmTimeval *, int **, char ***);
extern int _pmLogLookupInDom(_pmLogCtl *, pmInDom, _pmTimeval *, char *);
extern int _pmLogNameInDom(_pmLogCtl *, pmInDom, _pmTimeval *, int, char **);
extern int _pmLogPutResult(_pmLogCtl *, _pmPDU *);
extern int _pmLogFetch(_pmContext *, int, pmID *, pmResult **);
extern int _pmLogFetchInterp(_pmContext *, int, pmID *, pmResult **);
extern void _pmLogSetTime(_pmContext *);
extern void _pmLogResetInterp(_pmContext *);
extern int _pmLogChangeVol(_pmLogCtl *, int);
#include <dirent.h>
/* This is the directory where pmlogger creates the file containing the port
* number it is using.
*/
#define PM_LOG_PORT_DIR "/var/tmp/pmlogger"
/* The primary logger creates a symbolic link to its own port file
* in PM_LOG_PORT_DIR. This is the name of the link.
*/
#define PM_LOG_PRIMARY_LINK "primary"
/* The primary logger creates this file in PM_LOG_PORT_DIR containing the port
* number of the VCR control port
*/
#define PM_LOG_VCR_FILE "vcr"
/* struct for maintaining information about pmlogger ports */
typedef struct {
int pid; /* process id of logger */
int port; /* internet port for logger control */
char *pmcd_host; /* host pmlogger is collecting from */
char *archive; /* archive base pathname */
char *name; /* file name (minus dirname) */
} _pmLogPort;
/* Returns control port info for a pmlogger given its pid.
* If pid == -1, get all pmloggers' control ports.
* Note: do NOT free any part of result returned via the parameter.
*
* _pmLogFindPort(char *hostname, int pid, _pmLogPort **result);
*/
extern int _pmLogFindPort(char *, int, _pmLogPort **);
#define PM_LOG_ALL_PORTS -1 /* return ports for all pmloggers */
/* Logging Control */
extern int _pmConnectLogger(char *, int);
#define PM_LOG_CONTROL_PORT 0 /* ports for primary pmlogger */
#define PM_LOG_VCR_PORT 1
extern int _pmControlLog(int, pmResult *, int, int, int, pmResult **);
#define PM_LOG_OFF 0 /* state */
#define PM_LOG_MAYBE 1
#define PM_LOG_ON 2
#define PM_LOG_MANDATORY 11 /* control */
#define PM_LOG_ADVISORY 12
#define PM_LOG_ENQUIRE 13
/* macros for logging control values from _pmControlLog() */
#define PMLC_SET_ON(val, flag) \
val = (val & ~0x1) | (flag & 0x1)
#define PMLC_GET_ON(val) \
(val & 0x1)
#define PMLC_SET_MAND(val, flag) \
val = (val & ~0x2) | ((flag & 0x1) << 1)
#define PMLC_GET_MAND(val) \
((val & 0x2) >> 1)
#define PMLC_SET_AVAIL(val, flag) \
val = (val & ~0x4) | ((flag & 0x1) << 2)
#define PMLC_GET_AVAIL(val) \
((val & 0x4) >> 2)
#define PMLC_SET_INLOG(val, flag) \
val = (val & ~0x8) | ((flag & 0x1) << 3)
#define PMLC_GET_INLOG(val) \
((val & 0x8) >> 3)
#define PMLC_SET_STATE(val, state) \
val = (val & ~0xf) | (state & 0xf)
#define PMLC_GET_STATE(val) \
(val & 0xf)
/* 28 bits of delta, 32 bits of state */
#define PMLC_MAX_DELTA 0x0fffffff
#define PMLC_SET_DELTA(val, delta) \
val = (val & 0xf) | (delta << 4)
#define PMLC_GET_DELTA(val) \
(((val & ~0xf) >> 4) & PMLC_MAX_DELTA)
/* PDU_DATA_X subtypes exchanged between pmlc and pmlogger */
#define PMLC_PDU_STATUS_REQ 1
#define PMLC_PDU_STATUS 2
#define PMLC_PDU_NEWVOLUME 3
#define PMLC_PDU_SYNC 4
/*
* NOTE ... MAXHOSTNAMELEN is a bad choice here for ls_hostname[], as
* it may vary on different hosts ... we use MAXHOST instead, and
* size this to be the same as for IRIX, circa 5.3
*/
#define MAXHOST 64
/* pmlogger returns one of these when a status request is made */
typedef struct {
_pmTimeval ls_start; /* start time for log */
_pmTimeval ls_last; /* last time log written */
_pmTimeval ls_timenow; /* current time */
int ls_state; /* state of log (from _pmLogCtl) */
int ls_vol; /* current volume number of log */
long long ls_size; /* size of current volume */
char ls_hostname[MAXHOST];
/* name of collection host */
char ls_tz[40]; /* $TZ at collection host */
char ls_tzlogger[40]; /* $TZ at pmlogger */
} _pmLoggerStatus;
/* reporting timezone */
extern int _pmUseZone(const int);
extern int _pmNewZone(const char *);
extern int _pmNewContextZone(void);
extern int _pmWhichZone(char **);
extern char *_pmCtime(const time_t *, char *);
extern struct tm *_pmLocaltime(const time_t *, struct tm *);
extern time_t _pmMktime(struct tm *);
/* reverse ctime and time interval parsing */
extern int _pmParseInterval(char *, struct timeval *, char **);
extern int _pmParseCtime(char *, struct tm *, char **);
extern int _pmConvertTime(struct tm *, struct timeval *, struct timeval *);
extern int _pmParseTime(
char *, struct timeval *, struct timeval *,
struct timeval *, char **);
/* mainupulate internal timestamps */
extern double _pmTimevalSub(_pmTimeval *, _pmTimeval *);
/* 32-bit file checksum */
extern __int32_t _pmCheckSum(FILE *);
/* check for localhost */
extern int _pmIsLocalhost(char *);
/* host:metric[instances] or archive/metric[instances] */
typedef struct {
int isarch; /* source type: 0 -> live host, 1 -> archive */
char *source; /* name of source host or archive */
char *metric; /* name of metric */
int ninst; /* number of instances, 0 -> all */
char *inst[1]; /* array of instance names */
} _pmMetricSpec;
/* parsing of host:metric[instances] or archive/metric[instances] */
extern int _pmParseMetricSpec(char *, int, char *, _pmMetricSpec **, char **);
#define _pmFreeMetricSpec(p) free(p)
/*
* struct timeval manipulations
*/
extern double _timevalAdd(struct timeval *, struct timeval *);
extern double _timevalSub(struct timeval *, struct timeval *);
/*
* interface to _pmGetPDU() controls
*/
extern int _pmMoreInput(int);
extern void _pmNoMoreInput(int);
/*
* time control internal API
*/
#define PM_TCTL_PROTO_VERSION 1 /* protocol version number */
/* internal commands */
#define PM_TCTL_ACK 16 /* used by pmTimeSendAck */
#define PM_TCTL_INITIALIZE 17 /* used by pmTimeConnect */
#define PM_TCTL_MASTER_PATH "/usr/pcp/bin/pmtime"
/* time control client */
typedef struct {
int toClient; /* server sends socket */
int fromClient; /* server receive socket */
int wantAck; /* nonzero => ACK expected */
int version; /* protocol version used by the client */
pmTime data; /* client state data */
} _pmTimeClient;
/* time control timezone */
typedef struct {
char *label; /* label to name tz */
char *tz; /* env $TZ */
int handle; /* handle from _pmNewZone() */
} _pmTimeZone;
/* time control state */
typedef struct {
int mode; /* mode bitmap */
int control; /* control port (socket) */
char *port; /* NULL if standalone */
pmTime data; /* synchronized state */
int numclients; /* number of clients */
_pmTimeClient *clients; /* array of clients */
int numtz; /* number of timezones */
_pmTimeZone *tz; /* array of time zones */
} _pmTimeState;
/* pdu structure for PM_TCTL_INITIALIZE */
typedef struct {
int version; /* version number */
pmTime params; /* user's parameters */
} _pmTimeInitPDU;
/*
* Create control port on the given named pipe, then bind and listen.
* This is for use by X11 widgets and the pmTimeMaster main program.
*/
extern int _pmTimeInit(char *, pmTime *); /* port, initState */
/* close control port, close and free all clients, free internal state */
extern int _pmTimeClose(void);
/* get pointer to internal time control state (static in timecontrol.c) */
extern int _pmTimeGetState(_pmTimeState **);
/* accept a new client, return err */
extern int _pmTimeAcceptClient(int *, int *, pmTime *); /* toClient*, fromClient*, initparams */
/* initialize a new time control client on given sockets|pipe */
extern int _pmTimeAddClient(int, int); /* toClient, fromClient */
/* find a client (keyed by it's send file descriptor) */
extern _pmTimeClient *_pmTimeFindClient(int); /* fd */
/* add a new time control timezone */
extern int _pmTimeAddTimezone(char *, char *); /* label, tz */
/* find a previously added timezone by it's label, return it's handle */
extern int _pmTimeGetTimezone(char *);
/* delete and free a time control client (on given sndFd) */
extern int _pmTimeDelClient(int);
/* send a time control command to all clients, return err or 0 */
extern int _pmTimeBroadcast(int, pmTime *); /* cmd, data */
/*
* return the number of clients with pending ACKS.
* If timeout is non-NULL and there are acks pending,
* block in select until any client is ready.
*/
extern int _pmTimeAcksPending(struct timeval *); /* timeout */
extern void _pmTimeSetHungClients(void);
/* low level time control PDU transmit */
extern int _pmTimeSendPDU(int, int, pmTime *); /* fd, cmd, state */
/* low level time control PDU receive, returns recv'ed command */
extern int _pmTimeRecvPDU(int, pmTime *); /* fd, state */
/* debug routines */
extern char *_pmTimeCmdStr(int);
extern char *_pmTimeStateStr(int);
extern char *_pmTimeStr(pmTime *);
/*
* Interface Definitions for PMDA DSO Interface
* This is the original structure, kept for backwards compatibility.
* Use pmdaInterface and pmdaMain instead.
*/
typedef struct {
int domain; /* set/return performance metrics domain id here */
struct {
unsigned int version : 4; /* protocol version */
unsigned int flags : 24; /* usage TBD */
} comm; /* set/return communication and version info */
int status; /* return initialization status here */
int (*profile)(_pmProfile *prof);
int (*fetch)(int numpmid, pmID pmidlist[], pmResult **result);
int (*desc)(pmID pmid, pmDesc *desc);
int (*instance)(pmInDom indom, int inst, char *name,
_pmInResult **result);
int (*text)(int ident, int type, char **buffer);
int (*control)(pmResult *request, int control, int state,
int rate);
int (*store)(pmResult *result);
} _pmPMDA;
void pmdaMainLoop(char *, int, int, _pmPMDA *, int (*)(void), void (*)(void));
/*
* record session support
*/
#define PM_REC_OFF 40
#define PM_REC_BEGIN 41
#define PM_REC_HOST 42
#define PM_REC_ON 43
#define PM_REC_DETACH 44
extern FILE *_pmRecordSetup(char *, char *, int);
extern FILE *_pmRecordAddHost(char *);
extern int _pmRecordControl(int);
extern char *_pmRecordStatus(int);
/*
* Map PMAPI error codes between PCP 1.x and PCP 2.0 and vice versa
* -1000 is start of PCP 1.x errors
* 0xc0000000 assumes no more than 2**30 PCP 2.0 errors
* Examples 1.x 2.0
* -1000 0x80000000
* -1001 0x80000001
* -1050 0x80000032
*/
#define PM_ERR_20_TO_1X(v) (v < 0 && v < 0xc0000000 ? -((v & 0x7fffffff)+1000) : v)
#define PM_ERR_1X_TO_20(v) (v <= -1000 ? 0x80000000+(-(v+1000)) : v)
/*
* path to pmLaunch scripts
*/
#define PM_LAUNCH_PATH "/var/pcp/config/pmlaunch/"
#define PM_LAUNCH_RC "/var/pcp/config/pmlaunch/pmlaunchrc"
#ifdef __cplusplus
}
#endif
#endif /* _IMPL_H */